const detectBrowserEngine = (): string => {
  const userAgent = window.navigator.userAgent
  let engine = 'Unknown'

  // Trident
  if (/Trident\/|MSIE/.test(userAgent)) {
    engine = 'Trident'
  }
  // Blink
  else if (/Chrome/.test(userAgent) && !/Edge/.test(userAgent)) {
    engine = 'Blink'
  }
  // WebKit
  else if (/AppleWebKit/.test(userAgent) && !/Chrome/.test(userAgent)) {
    engine = 'WebKit'
  }
  // Gecko
  else if (/Gecko\//.test(userAgent) && !/like Gecko/.test(userAgent)) {
    engine = 'Gecko'
  }

  return engine
}

export { detectBrowserEngine }
